package com.wolfpire.info.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.wolfpire.info.dao.ProfessionalCountInfoDao;
import com.wolfpire.info.dao.ProfessionalDetailCountInfoDao;
import com.wolfpire.info.model.ProfessionalCountInfo;
import com.wolfpire.info.model.ProfessionalDetailCountInfo;
import com.wolfpire.info.service.ProfessionalCountInfoService;
import com.wolfpire.system.common.Constants;
import com.wolfpire.system.common.Page;
import com.wolfpire.system.common.base.dao.IBaseHibernateDao;
import com.wolfpire.system.common.base.service.impl.BaseHibernateService;

@Service("professionalCountInfoService")
public class ProfessionalCountInfoServiceImpl extends
		BaseHibernateService<ProfessionalCountInfo, Long> implements
		ProfessionalCountInfoService {
	
	@Override
	public void saveOrUpdate(ProfessionalCountInfo professionalCountInfo, List<ProfessionalDetailCountInfo> professionalDetailCountInfos) {

		this.professionalCountInfoDao.saveOrUpdate(professionalCountInfo);
		this.professionalDetailCountInfoDao.deleteByProfessionalCountInfoId(professionalCountInfo.getId());
		this.professionalDetailCountInfoDao.batchSave(professionalDetailCountInfos, professionalCountInfo.getId());
	}

	@Override
	public List<ProfessionalCountInfo> list(ProfessionalCountInfo professionalCountInfo) {
		return this.professionalCountInfoDao.list(professionalCountInfo);
	}

	@Override
	public void del(Long id) {
		// TODO Auto-generated method stub
		ProfessionalCountInfo info = this.professionalCountInfoDao.get(id);
		if (null != info) {
			info.setDelFlag(Constants.DELETE_FLAG);
			this.professionalCountInfoDao.saveOrUpdate(info);
		}
	}

	@Override
	public Page<ProfessionalCountInfo> setPageDataList(
			Page<ProfessionalCountInfo> page,
			ProfessionalCountInfo filterProfessionalCountInfo) {
		return this.professionalCountInfoDao.findProfessionalCountInfos(page, filterProfessionalCountInfo);
	}

	@Override
	public List<ProfessionalDetailCountInfo> getProfessionalDetailCountInfos(
			Long id) {
		ProfessionalDetailCountInfo professionalDetailCountInfo = new ProfessionalDetailCountInfo();
		professionalDetailCountInfo.setProfessionalCountInfoId(id);
		return this.professionalDetailCountInfoDao.list(professionalDetailCountInfo);
	}

	@Override
	protected IBaseHibernateDao<ProfessionalCountInfo, Long> getEntityDao() {
		return this.professionalCountInfoDao;
	}
	
	@Resource private ProfessionalCountInfoDao professionalCountInfoDao;
	
	@Resource private ProfessionalDetailCountInfoDao professionalDetailCountInfoDao;
}
